﻿using System;
using System.Collections.Generic;

namespace Domain
{
    public class LengthConverter
    {
        private IDictionary<string, double> multiplyToMeter = new Dictionary<string, double>()
        {
            {"meter", 1.0},
            {"inch", 0.0254},
            {"centimeter", 0.01}
        };
        public IDictionary<string, double> MultiplyToMeter
        {
            get
            {
                return multiplyToMeter;
            }
            set
            {
                if (value == null)
                    throw new ArgumentNullException();
                multiplyToMeter = value;
            }
        }
        public LengthConverter()
        {
            MultiplyToMeter = multiplyToMeter;
        }
        public double Convert(double from, string fromType, string toType)
        {
            if (!MultiplyToMeter.ContainsKey(fromType) || !MultiplyToMeter.ContainsKey(toType))
                throw new ArgumentException();
            return from * MultiplyToMeter[fromType] / MultiplyToMeter[toType];
        }
    }
}